# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=prompt_toolkit
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.0.14
pkgrel=1
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}=${pkgver}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgdesc="Library for building powerful interactive command lines in Python (mingw-w64)"
url="https://github.com/jonathanslenders/python-prompt-toolkit"
arch=('any')
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python-wcwidth")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
source=(python-prompt-toolkit-${pkgver}.tar.gz::https://github.com/jonathanslenders/python-prompt-toolkit/archive/${pkgver}.tar.gz)
sha256sums=('594e14dda6e9fd564cfbfcaed1030d5f8cdbb4049749b67c863831a5a852958d')

prepare() {
  cd "${srcdir}"
  rm -rf python-build-${CARCH} | true
  cp -r "python-prompt-toolkit-${pkgver}" "python-build-${CARCH}"

  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/py.test || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-build-${CARCH}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py install --root=${pkgdir} \
   --prefix=${MINGW_PREFIX} --optimize=1 --skip-build

  install -Dm644 LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
